<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <link rel="stylesheet" href="/webjars/bootstrap/3.3.7/css/bootstrap.css">
  <script src="/webjars/jquery/3.4.1/jquery.js" type="text/javascript"></script>
  <script type="text/javascript" src="/webjars/bootstrap/3.3.7/js/bootstrap.js"></script>
  <script type="text/javascript" src="/webjars/vue/2.6.10/dist/vue.js"></script>
  <script src="/webjars/axios/0.19.0/dist/axios.js" type="text/javascript"></script>
</head>
<body>
  <div id="vuebox">
  <div class="container">
    <form class="form-horizontal" role="form">
      <div class="form-group">
        <label for="firstname" class="col-sm-2 control-label">用户名</label>
        <div class="col-sm-10">
          <input type="text" class="form-control" v-model="name" id="firstname" placeholder="请输入用户名">
        </div>
      </div>
      <div class="form-group">
        <label for="lastname" class="col-sm-2 control-label">密码</label>
        <div class="col-sm-10">
          <input type="password" class="form-control" v-model="password" id="lastname" placeholder="请输入密码">
        </div>
      </div>
      <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
          <button type="button" class="btn btn-default"  @click="dologin">登录</button>
        </div>
      </div>
    </form>
  </div>
  </div>
</body>
</html>
<script type="text/javascript">
        var vm=new Vue({
            el:"#vuebox",
            data:{
                name:"",
                password:"",
                result:""
            },
            methods:{
                dologin:function () {
                    axios.get("/dologin",{params:{name:this.name,password:this.password}}).then(res=>{
                       this.result=res.data;
                        if(this.result.msg.id==undefined){
                        alert(this.result.msg)
                        }else{
                            window.location.href="/tomain?id="+this.result.msg.id;
                        }
                    })
                }
            }

    })
</script>